package cn.iocoder.yudao.module.peizhen.dal.mysql.opencity;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.peizhen.dal.dataobject.opencity.OpenCityDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.peizhen.controller.admin.opencity.vo.*;

/**
 * 服务开通城市 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface OpenCityMapper extends BaseMapperX<OpenCityDO> {

    default PageResult<OpenCityDO> selectPage(OpenCityPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<OpenCityDO>()
                .eqIfPresent(OpenCityDO::getType, reqVO.getType()).eq(OpenCityDO::getOpen,1)
                .likeIfPresent(OpenCityDO::getName, reqVO.getName())
                .eqIfPresent(OpenCityDO::getParentId, reqVO.getParentId())
                .betweenIfPresent(OpenCityDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(OpenCityDO::getId));
    }


    default OpenCityDO selectByName(String cityName){
        OpenCityDO openCityDO = selectOne(new LambdaQueryWrapperX<OpenCityDO>().eqIfPresent(OpenCityDO::getName, cityName));
        return  openCityDO;
    }
}